package com.by.user.controller;

import com.by.user.api.service.IUserService;
import com.by.user.api.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private IUserService userService;
    
    @PostMapping("/register")
    public UserVo register(@RequestParam String username, @RequestParam String password) {
        return userService.register(username, password);
    }
    
    @PostMapping("/login")
    public UserVo login(@RequestParam String username, @RequestParam String password) {
        return userService.login(username, password);
    }
    
    @GetMapping("/{id}")
    public UserVo getUserById(@PathVariable Long id) {
        return userService.getUserById(id);
    }
}